<?php
class mformulir extends CI_Model{
	var $menu = "formulir_begolden";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_pendaftar,$nama_pendaftar,$no_identitas,$alamat_pendaftar,$telp_1_pendaftar,$telp_2_pendaftar,$fax_pendaftar,$email_pendaftar,$alamat_lokasi,$telp_lokasi,$lebar_lokasi,$panjang_lokasi,$estimasi_anggaran,$upload_pas_foto,$upload_lokasi,$tgl_daftar)
	{
		$this->id_pendaftar= $id_pendaftar;
		$this->nama_pendaftar= $nama_pendaftar;
		$this->no_identitas= $no_identitas;
		$this->alamat_pendaftar= $alamat_pendaftar;
		$this->telp_1_pendaftar= $telp_1_pendaftar;
		$this->telp_2_pendaftar= $telp_2_pendaftar;
		$this->fax_pendaftar= $fax_pendaftar;
		$this->email_pendaftar= $email_pendaftar;
		$this->alamat_lokasi= $alamat_lokasi;
		$this->telp_lokasi= $telp_lokasi;
		$this->lebar_lokasi= $lebar_lokasi;
		$this->panjang_lokasi= $panjang_lokasi;
		$this->estimasi_anggaran= $estimasi_anggaran;
		$this->upload_pas_foto= $upload_pas_foto;
		$this->upload_lokasi= $upload_lokasi;
		$this->tgl_daftar= $tgl_daftar;
	}
	
	function getList($page,$uri_segment){
		$query = $this->db->get($this->menu, $page, $uri_segment);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{	
		$arrayData = array(
			'id_pendaftar'=>$this->id_pendaftar,
			'nama_pendaftar'=>$this->nama_pendaftar,
			'no_identitas'=>$this->no_identitas,
			'alamat_pendaftar'=>$this->alamat_pendaftar,
			'telp_1_pendaftar'=>$this->telp_1_pendaftar,
			'telp_2_pendaftar'=>$this->telp_2_pendaftar,
			'fax_pendaftar'=>$this->fax_pendaftar,
			'email_pendaftar'=>$this->email_pendaftar,
			'alamat_lokasi'=>$this->alamat_lokasi,
			'telp_lokasi'=>$this->telp_lokasi,
			'lebar_lokasi'=>$this->lebar_lokasi,
			'panjang_lokasi'=>$this->panjang_lokasi,
			'estimasi_anggaran'=>$this->estimasi_anggaran,
			'upload_pas_foto'=>$this->upload_pas_foto,
			'upload_lokasi'=>$this->upload_lokasi,
			'tgl_daftar'=>$this->tgl_daftar
		);
		return $this->db->insert($this->menu, $arrayData);
	}
	
	function update($id_pendaftar)
	{
		$arrayData = array(
			'nama_pendaftar'=>$this->nama_pendaftar,
			'no_identitas'=>$this->no_identitas,
			'alamat_pendaftar'=>$this->alamat_pendaftar,
			'telp_1_pendaftar'=>$this->telp_1_pendaftar,
			'telp_2_pendaftar'=>$this->telp_2_pendaftar,
			'fax_pendaftar'=>$this->fax_pendaftar,
			'email_pendaftar'=>$this->email_pendaftar,
			'alamat_lokasi'=>$this->alamat_lokasi,
			'telp_lokasi'=>$this->telp_lokasi,
			'lebar_lokasi'=>$this->lebar_lokasi,
			'panjang_lokasi'=>$this->panjang_lokasi,
			'estimasi_anggaran'=>$this->estimasi_anggaran,
			'upload_pas_foto'=>$this->upload_pas_foto,
			'upload_lokasi'=>$this->upload_lokasi,
			'tgl_daftar'=>$this->tgl_daftar
		);
		$this->db->where('id_pendaftar', $id_pendaftar);
		return $this->db->update($this->menu, $arrayData);
	}
        
	function remove($id_pendaftar)
	{
		$this->db->where('id_pendaftar', $id_pendaftar);
		return $this->db->delete($this->menu);
	}	
	
	function detail($id_pendaftar)
	{
		$this->db->where('id_pendaftar', $id_pendaftar);
		$query = $this->db->get($this->menu);	
		return $query->result_array();
	}
	
	function getListSearch($name){
		$this->db->like('nama_pendaftar',$name);
		$query = $this->db->get($this->menu);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
}
?>